package linter.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import linter.POJO.DO.LikesContent;
import linter.service.LikesContentService;
import linter.mapper.LikesContentMapper;
import linter.utils.PropertyUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

import static linter.custom.CustomResultType.LIKES_ERROR;
import static linter.custom.CustomResultType.LIKES_SUCCESS;

/**
* @author 北煜
* @description 针对表【likes_content(评论点赞详情表)】的数据库操作Service实现
* @createDate 2024-03-18 21:09:11
*/
@Service
public class LikesContentServiceImpl extends ServiceImpl<LikesContentMapper, LikesContent>
    implements LikesContentService{

    @Resource
    LikesContentMapper likesContentMapper;

    @Override
    public String updateLikeNub(Long uuid, Integer commentsId) {
        Date date = new Date();
        LikesContent likesContent = new LikesContent();
        likesContent.setContentId(commentsId);
        likesContent.setUuid(uuid);
        likesContent.setCreateTime(date);
        likesContent.setUpdateTime(date);
        int flag = likesContentMapper.insert(PropertyUtils.doToDto(likesContent, LikesContent.class));
        return flag == 1 ? LIKES_SUCCESS : LIKES_ERROR;
    }
}




